package com.mingqi.enetconnected.view.Dialog;

import android.app.Dialog;
import android.content.Context;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.view.View;
import android.widget.TextView;
import android.widget.Toast;

import com.mingqi.enetconnected.R;

/**
 * Created by li on 2018/8/22.
 * WeChat 18571658038
 * author LiWei
 */

public class CommonDialog extends Dialog {

    private TextView mTvHint;
    private TextView mTvYes;
    private TextView mTvNo;
    private String mHintMsg;

    public CommonDialog(@NonNull Context context, String hintMsg) {

        super(context, R.style.MyBaseDialog);
        mHintMsg = hintMsg;
    }

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.dialog_common_hint);

        mTvHint = findViewById(R.id.tv_hint);
        mTvYes = findViewById(R.id.tv_yes);
        mTvNo = findViewById(R.id.tv_no);

        mTvHint.setText(mHintMsg);

        mTvNo.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                dismiss();
            }
        });
    }

    public void setHintMessage(String hintMsg){

        mTvHint.setText(hintMsg);
    }
    public void setYesMessage(String yesMsg){

        mTvYes.setText(yesMsg);
    }
    public void setNoMsg(String noMsg){

        mTvNo.setText(noMsg);
    }

    public void setOnConfirmListener(final OnConfirmListener yesListener){

        mTvYes.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

                yesListener.setOnConfirmClick(CommonDialog.this);
            }
        });
    }

    public interface OnConfirmListener{

        void setOnConfirmClick(CommonDialog instance);
    }
}
